package com.example.thread.d9CompletableFuture2.d2RunAsync;

import com.example.thread.d9CompletableFuture2.CommonUtils;

import java.util.concurrent.CompletableFuture;

public class RunAsyncDemo1 {
    public static void main(String[] args) {
        // runAsync创建异步任务
        CommonUtils.printThreadLog("main start");
        // 使用Runnable匿名内部类
        CompletableFuture.runAsync(() -> {
            CommonUtils.printThreadLog("读取文件开始");
            CommonUtils.sleepSecond(3);
            CommonUtils.printThreadLog("读取文件结束");
        });
        CommonUtils.printThreadLog("here are not blocked,main continue");
        CommonUtils.sleepSecond(4);
        CommonUtils.printThreadLog("main end");
    }
}
